package com.example.agriculturemachine.ui.adapter;

import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;

import java.util.List;

public class IntroductoryAdapter extends PagerAdapter {
    private List<View> list;

    public IntroductoryAdapter(List<View> list){
        this.list=list;
    }


    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public boolean isViewFromObject(@NonNull  View view, @NonNull  Object object) {
        return view==object;
    }


    //预加载子页面
    @Override
    public Object instantiateItem(@NonNull  ViewGroup container, int position) {
        View view = list.get(position);
        container.addView(view);

        return view;
    }

    //用来销毁某个子页面释放资源
    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull  Object object) {
        container.removeView(list.get(position));
    }
}
